import { Vec3, Node } from "cc";
import { GridSensorBase, ProcessCollidersMethod } from "./GridSensorBase";
import { SensorCompressionType } from "./CompressionSpec";


/**
 * @en
 * Grid-based sensor with one-hot observations.
 * 
 * @zh
 * 具有 one-hot 观察的基于网格的传感器。
 */
export class OneHotGridSensor extends GridSensorBase {
    constructor(
        _name: string,
        _cellScale: Vec3,
        _gridSize: Vec3,
        _detectableTags: string[],
        _compression: SensorCompressionType
    ) {
        super(_name, _cellScale, _gridSize, _detectableTags, _compression);
    }

    protected override getCellObservationSize(): number {
        return this.detectableTags == null ? 0 : this.detectableTags.length;
    }

    protected override isDataNormalized(): boolean {
        return true;
    }

    override getProcessCollidersMethod(): ProcessCollidersMethod {
        return ProcessCollidersMethod.ProcessClosestColliders;
    }

    protected override getObjectData(detectedObject: Node, tagIndex: number, dataBuffer: number[]): void {
        dataBuffer[tagIndex] = 1;
    }
}